<?php
class system_user_instance {

	private static $_instance;
	/**
	 * @return system_user_instance
	 */
	static public function getInstance() {
		if(null === self::$_instance) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}
	
	protected static $_user = null;
	/**
	 * @return system_user_row
	 */
	public static function getRow() {
		if(null === self::$_user && ($passportId = intval(self::getInstance()->getSession()->getId())) > 0) {
			$concept = new system_user_concept();
			self::$_user = $concept->fetch(array('user.id = ?' => $passportId));
			if(self::$_user) {
				system_nav_language::getInstance()->setTimezone(self::$_user->getTimezone());
			}
		}
		return self::$_user;
	}
	
	private $_session = null;
	/**
	 * @return system_passport_session
	 */
	public function getSession() {
		if(null === $this->_session) {
			$this->_session = new system_passport_session('USER');
		}
		return $this->_session;
	}
}
